import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../config.dart' show Constants, AppColors;
/**
 * @Author: zhouge
 * @Description: 通用组件按钮组件
 * @Date: Created in 20:56 2020-09-28
 * @Modified By:
 **/

class FullWidthIconButton extends StatelessWidget {
  // 一般常量，放在控件中单独进行管理。
  static const HORIZONTAL_PADDING = 20.0;
  static const VERTICAL_PADDING = 13.0;

  // 构造函数
  const FullWidthIconButton({
    @required this.iconPath,
    @required this.title,
    @required this.onPressed,
    this.showDivider: false,
  })  : assert(iconPath != null),
        assert(title != null),
        assert(onPressed != null);

  // 参数
  final String iconPath;
  final String title;
  final VoidCallback onPressed;
  final bool showDivider; // 分割线

  @override
  Widget build(BuildContext context) {
    final pureButton = Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Image.asset(
          iconPath,
          width: Constants.FullWidthIconButtonSize,
          height: Constants.FullWidthIconButtonSize,
        ),
        SizedBox(width: HORIZONTAL_PADDING),
        Text(title),
        Expanded(
          child: Text(''),
        ),
        Column(
          children: <Widget>[
            Icon(
              Icons.arrow_forward_ios,
              color: Color(AppColors.DividerColor),
              size: Constants.DiscoverRowButtonSize,
            ),
          ],
        )
      ],
    );
    return Container(
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  width: Constants.DividerWidth,
                  color: Color(AppColors.DividerColor)))),
      child: FlatButton(
        padding: const EdgeInsets.only(
          left: HORIZONTAL_PADDING, right: HORIZONTAL_PADDING,
          bottom: VERTICAL_PADDING, top: VERTICAL_PADDING,
        ),
        color: Colors.white,
        onPressed: onPressed,
        child: pureButton,
      ),
    );
  }
}
